package com.happycat.controller.social;

import com.happycat.base.R;
import com.happycat.base.context.BaseContextHandler;
import com.happycat.mobile.service.UserAccountService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author shenbin
 * @CreatedDate 2020-09-10
 * @Modified By:
 */
@RestController
@RequestMapping("/social")
@Api(tags = "API-声网对接", value = "账户token等")
public class SocialController {
    @Autowired
    private UserAccountService userAccountService;

    @ApiOperation(value = "获取声网账户userId", notes = "若不指定用户，则获取当前用户, 若结果为空，系统将新建")
    @ApiImplicitParam(name="accountId", value = "用户id", required = false)
    @GetMapping(value = "getImUserId")
    public R<String> getImUserId(@RequestParam(value = "accountId", required = false) Long accountId){
        if(accountId==null || accountId<0){
            accountId = BaseContextHandler.getUserId();
        }
        return R.success(userAccountService.getImUserId(accountId));
    }

    //TODO 获取声网token

    //TODO 刷新声网token

}
